package edu.scau.mis.cloth.service.impl;

import edu.scau.mis.cloth.entity.GsAttrs;
import edu.scau.mis.cloth.dao.GsAttrsDao;
import edu.scau.mis.cloth.service.GsAttrsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * (GsAttrs)表服务实现类
 *
 * @author CJW
 * @since 2022-04-02 20:28:04
 */
@Service("gsAttrsService")
public class GsAttrsServiceImpl implements GsAttrsService {
    @Resource
    private GsAttrsDao gsAttrsMapper;

    public List<Map<String,Object>> checkInventoryById(Integer clId){
        return gsAttrsMapper.checkInventoryById(clId);
    }

    public List<Map<String,Object>> checkInventoryByCategory(){
        return gsAttrsMapper.checkInventoryByCategory();
    }

    public List<Map<String,Object>> checkInventoryBySize(){
        return gsAttrsMapper.checkInventoryBySize();
    }
    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public GsAttrs queryById(Integer id) {
        return this.gsAttrsMapper.queryById(id);
    }

    /**
     * 查询指定行
     *
     * @param gsAttrs 筛选条件
     * @return 查询结果
     */
    @Override
    public List<GsAttrs> queryAll(GsAttrs gsAttrs) {
        return this.gsAttrsMapper.queryAll(gsAttrs);
    }

    /**
     * 新增数据
     *
     * @param gsAttrs 实例对象
     * @return 实例对象
     */
    @Override
    public GsAttrs insert(GsAttrs gsAttrs) {
        this.gsAttrsMapper.insert(gsAttrs);
        return gsAttrs;
    }

    /**
     * 修改数据
     *
     * @param gsAttrs 实例对象
     * @return 实例对象
     */
    @Override
    public GsAttrs update(GsAttrs gsAttrs) {
        this.gsAttrsMapper.update(gsAttrs);
        return this.queryById(gsAttrs.getId());
    }


    public int getInventory(Integer clId,String clSize){
        return gsAttrsMapper.getInventory(clId,clSize);

    }

    public void updateInventory(Integer clId,String clSize,int inventory){
        gsAttrsMapper.updateInventory(clId,clSize,inventory);
    }
    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.gsAttrsMapper.deleteById(id) > 0;
    }

    @Override
    public List queryAll() {
        return null;
    }
}
